<template>
  <div class="app-container home">
    <div class="container_top">
      <div class="container_title">运营重点监测</div>
      <div class="container_subtitle">
        <span>考核范围：2023.01.01 - 2023.11.30</span><span>同期：2022.01.01 - 2022.11.30</span><span>更新时间：2023.12.01</span>
      </div>
    </div>
    <el-row :gutter="8">
      <el-col :xs="24" :sm="12" :md="8" :lg="6" v-for="(item, index) in cardList1" :key="index" class="my-ul">
        <el-card shadow="never" :body-style="{ padding: '16px' }">
          <div class="card_title">
            {{ item.title }}
            <template v-if="item.renderHeader">
              <el-popover placement="bottom" trigger="click">
                <template #reference>
                  <a class="card_more" slot="reference"><el-icon size="14" style="vertical-align: middle;"><Setting /></el-icon><span style="padding-left: 6px;vertical-align: middle">更多要点</span></a>
                </template>
                <a v-for="(item, index) in item.headerList" :key="index" class="pop_btn" @click="check(item)">
                  <el-icon color="#333" size="14" style="vertical-align: middle"><Share /></el-icon><span style="padding-left: 12px;vertical-align: middle">{{ item.buttonName }}</span>
                </a>
              </el-popover>
            </template>
          </div>
          <div v-if="item.amplitude" class="card_num">
            <div class="card_n_title">本年度增幅</div>
            <div class="card_n_detail">{{ item.amplitude }}</div>
          </div>
          <div v-if="item.num" class="card_detail">
            <template v-if="isPositive(item.num) > 0">
              <div class="card_d_title">同比上升</div>
              <div class="card_d_detail" style="color: #019933">
                <span>{{ item.num }}</span><el-icon>
                  <CaretTop />
                </el-icon>
              </div>
            </template>
            <template v-else>
              <div class="card_d_title">同比下降</div>
              <div class="card_d_detail" style="color: #dd2100">
                <span>{{ formatPercentage(item.num) }}</span><el-icon><CaretBottom /></el-icon>
              </div>
            </template>
          </div>
          <div v-if="item.cardInfo" class="card_info">
            <div class="card_i" v-for="(item, index) in item.cardInfo" :key="index">
              <div class="card_i_title">{{ item.title }}</div>
              <div class="card_i_detail">{{ item.value }}</div>
            </div>
          </div>
          <div class="card_btn">
            <template v-if="item.renderFooter">
              <div class="card_btn_left">
                <el-button type="primary" plain size="small">{{ item.buttonName }}</el-button>
              </div>
              <div class="card_btn_right"></div>
            </template>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <div style="height: 24px"></div>
    <el-row :gutter="8">
      <el-col :xs="24" :sm="12" :md="8" :lg="6" v-for="(item, index) in cardList2" :key="index" class="my-ul">
        <el-card shadow="never" :body-style="{ padding: '16px' }">
          <div class="card_title">
            {{ item.title }}
            <template v-if="item.renderHeader">
              <el-popover placement="bottom" trigger="click">
                <template #reference>
                  <a v-for="(item, index) in item.headerList" :key="index" class="pop_btn" @click="check(item)"><i
                      class="el-icon-share" style="padding-right: 12px"></i>{{ item.buttonName }}</a>
                  <a class="card_more" slot="reference"><el-icon><Setting /></el-icon>更多要点</a>
                </template>
              </el-popover>
            </template>
          </div>
          <div v-if="item.amplitude" class="card_num">
            <div class="card_n_title">本年度增幅</div>
            <div class="card_n_detail">{{ item.amplitude }}</div>
          </div>
          <div v-if="item.num" class="card_detail">
            <template v-if="isPositive(item.num) > 0">
              <div class="card_d_title">同比上升</div>
              <div class="card_d_detail" style="color: #019933">
                <span>{{ item.num }}</span><el-icon><CaretTop /></el-icon>
              </div>
            </template>
            <template v-else>
              <div class="card_d_title">同比下降</div>
              <div class="card_d_detail" style="color: #dd2100">
                <span>{{ formatPercentage(item.num) }}</span><el-icon><CaretBottom /></el-icon>
              </div>
            </template>
          </div>
          <div v-if="item.cardInfo" class="card_info">
            <div class="card_i" v-for="(item, index) in item.cardInfo" :key="index">
              <div class="card_i_title">{{ item.title }}</div>
              <div class="card_i_detail">{{ item.value }}</div>
            </div>
          </div>
          <div class="card_btn">
            <template v-if="item.renderFooter">
              <div class="card_btn_left">
                <el-button type="primary" plain size="small">{{ item.buttonName }}</el-button>
              </div>
              <div class="card_btn_right"></div>
            </template>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup name="Operation">

const cardList1 = reactive([
  {
    title: '医疗收入服务占比',
    num: '5%',
    cardInfo: [
      {
        title: '医疗总收入',
        value: '1000万元'
      },
      {
        title: '医疗服务收入',
        value: '300万元'
      },
      {
        title: '人员支出占比',
        value: '30%'
      }
    ]
  },
  {
    title: '人员支出占业务支出比重',
    num: '-5%',
    cardInfo: [
      {
        title: '业务支出',
        value: '200万元'
      },
      {
        title: '人员支出',
        value: '100万元'
      },
      {
        title: '服务收入占比',
        value: '50%'
      }
    ],
    renderHeader: true,
    headerList: [
      { buttonName: '本省数据查看' }
    ],
    renderFooter: true,
    buttonName: '改进措施'
  },
  {
    title: '收支结余',
    num: '-5%',
    cardInfo: [
      {
        title: '医疗盈余',
        value: '30万元'
      },
      {
        title: '医疗活动收入',
        value: '1000万元'
      },
      {
        title: '收支结余',
        value: '3%'
      }
    ],
    renderHeader: true,
    headerList: [
      { buttonName: '本省数据查看' }
    ],
    renderFooter: true,
    buttonName: '情况说明'
  },
  {
    title: '资产负载率',
    num: '3%',
    cardInfo: [
      {
        title: '负债合计',
        value: '980万元'
      },
      {
        title: '资产合计',
        value: '1000万元'
      },
      {
        title: '资产负债率',
        value: '98%'
      }
    ],
    renderFooter: true,
    buttonName: '情况说明'
  },
  {
    title: '高值医用耗材收入占比',
    num: '-5%',
    cardInfo: [
      {
        title: '高值医用耗材收入',
        value: '300万元'
      },
      {
        title: '卫生材料收入',
        value: '1000万元'
      },
      {
        title: '群材收入占比',
        value: '30%'
      }
    ],
    renderFooter: true,
    buttonName: '情况说明'
  },
  {
    title: '万元收入能耗支出',
    num: '0.2%',
    cardInfo: [
      {
        title: '年总能耗',
        value: '1190吨标煤'
      },
      {
        title: '年总收入',
        value: '1000万元'
      },
      {
        title: '收支结余',
        value: '1.1%'
      }
    ],
    renderFooter: true,
    buttonName: '改进措施'
  }
])
const cardList2 = reactive([
  {
    title: '门诊次均费用增幅',
    amplitude: '116.39%',
    num: '50%',
    renderHeader: true,
    headerList: [
      { buttonName: '本省数据查看' }
    ],
    renderFooter: true,
    buttonName: '改进措施'
  },
  {
    title: '门诊次均药品费用增幅',
    amplitude: '148.39%',
    num: '50%',
    renderFooter: true,
    buttonName: '改进措施'
  },
  {
    title: '住院次均费用增幅',
    amplitude: '-5.48%',
    num: '-50%'
  },
  {
    title: '住院次均药品费用增幅',
    amplitude: '-4.1%',
    num: '-50%'
  }
])

function isPositive(item) {
  return parseFloat(item.replace('%', ''))
}
function formatPercentage(item) {
  return item.replace('-', '')
}
function check() {
  console.log("本省数据查看")
}
</script>

<style lang="scss" scoped>
.app-container {
  padding: 16px 16px;
  clear: both;

  &.home {
    overflow-x: hidden;
    height: 100%;
  }

  .container_top {
    width: 100%;
    height: 48px;
    margin-top: 4px;
    margin-bottom: 12px;
    display: flex;

    .container_title {
      text-align: left;
      font-size: 18px;
      font-weight: 600;
      line-height: 48px;
      flex: 1;
      padding-left: 6px;
    }

    .container_subtitle {
      font-size: 14px;
      line-height: 48px;
      color: #555555;
      padding-right: 6px;

      span {
        padding-left: 24px;
      }
    }
  }

  .my-ul {
    margin-bottom: 8px;

    .card_title {
      font-size: 15px;
      font-weight: 600;
      height: 30px;
      margin-bottom: 18px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding-left: 14px;
      position: relative;

      &:before {
        content: "";
        position: absolute;
        width: 4px;
        height: 12px;
        background: #0783ff;
        left: 0;
        margin: auto;
      }
    }

    .card_detail {
      font-size: 14px;
      display: flex;
      align-items: center;

      .card_d_title {
        flex: 1;
        text-align: left;
        font-weight: 600;
      }

      .card_d_detail {
        flex: 1;
        text-align: right;
        font-size: 14px;
        font-weight: 600;
      }
    }

    .card_info {
      padding-top: 16px;

      .card_i {
        display: flex;
        align-items: center;
        font-size: 13px;
        line-height: 26px;

        .card_i_title {
          flex: 1;
          text-align: left;
        }

        .card_i_detail {
          flex: 1;
          text-align: right;
        }
      }
    }

    .card_num {
      font-size: 14px;
      display: flex;
      align-items: center;
      padding-bottom: 12px;

      .card_n_title {
        flex: 1;
        text-align: left;
      }

      .card_n_detail {
        flex: 1;
        text-align: right;
        font-size: 16px;
      }
    }

    .card_btn {
      display: flex;
      margin-top: 12px;
      border-top: 1px solid #e5e5e5;
      padding-top: 12px;
      min-height: 41px;

      .card_btn_left {
        flex: 1;
        text-align: left;
      }

      .card_btn_right {
        flex: 1;
        text-align: right;
      }
    }
  }
}

a.pop_btn {
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card_more {
  font-size: 13px;
  color: #555555;
  font-weight: 400;
}
</style>
